package admin.main;

import com.opensymphony.xwork2.ActionSupport;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

import java.util.*;
import java.io.Reader;
import java.io.IOException;
import java.net.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.text.ParseException;

import admin.main.EventBoardVO;
import util.AdminCalendarView;

public class NewListAction extends ActionSupport{

	public static Reader reader;
	public static SqlMapClient sqlMapper;
	

	private List<EventBoardVO> eventlistAll = new ArrayList<EventBoardVO>();
	Calendar now_cal = Calendar.getInstance();
	private AdminCalendarView cal;
	private String nav;
	private String today;
	private int endDay;
	private int week;
	private int nowYear;
	private int nowMonth;
	private int nowDay;
	private int year;
	private int month;
	private int paramYear;
	private int paramMonth;

	public NewListAction() throws IOException
	{
		reader = Resources.getResourceAsReader("sqlMapConfig.xml");
		sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
		reader.close();		
	}
	
	public String execute() throws Exception {
		
		eventlistAll = sqlMapper.queryForList("newEselectAll");
	
		cal = new AdminCalendarView();
		if(paramMonth != nowYear){
			cal = new AdminCalendarView(paramYear, paramMonth);
		}
		nav = cal.getNav().toString();
		today = cal.getToday().toString();
		week = cal.getWeek();
		endDay = cal.getEndDay();
		nowYear=now_cal.get(Calendar.YEAR);
		nowMonth=now_cal.get(Calendar.MONTH)+1;
		nowDay=now_cal.get(Calendar.DAY_OF_MONTH);
		year = cal.getYear();
		month = cal.getMonth();
		
		return SUCCESS;
	}


	public List<EventBoardVO> getEventlistAll() {
		return eventlistAll;
	}

	public void setEventlistAll(List<EventBoardVO> eventlistAll) {
		this.eventlistAll = eventlistAll;
	}

	public String getNav() {
		return nav;
	}

	public void setNav(String nav) {
		this.nav = nav;
	}

	public String getToday() {
		return today;
	}

	public void setToday(String today) {
		this.today = today;
	}

	public int getEndDay() {
		return endDay;
	}

	public void setEndDay(int endDay) {
		this.endDay = endDay;
	}

	public int getWeek() {
		return week;
	}

	public void setWeek(int week) {
		this.week = week;
	}

	public int getNowYear() {
		return nowYear;
	}

	public void setNowYear(int nowYear) {
		this.nowYear = nowYear;
	}

	public int getNowMonth() {
		return nowMonth;
	}

	public void setNowMonth(int nowMonth) {
		this.nowMonth = nowMonth;
	}

	public int getNowDay() {
		return nowDay;
	}

	public void setNowDay(int nowDay) {
		this.nowDay = nowDay;
	}

	public int getYear() {
		return year;
	}

	public void setYear(int year) {
		this.year = year;
	}

	public int getMonth() {
		return month;
	}

	public void setMonth(int month) {
		this.month = month;
	}

	public int getParamYear() {
		return paramYear;
	}

	public void setParamYear(int paramYear) {
		this.paramYear = paramYear;
	}

	public int getParamMonth() {
		return paramMonth;
	}

	public void setParamMonth(int paramMonth) {
		this.paramMonth = paramMonth;
	}
	
	
}
